package d9_com.itheima.Date_jdk8;


import java.time.LocalDate;
import java.time.LocalTime;

public class Test2_LocalTime {
    public static void main(String[] args) {
        //0、获取本地时间对象
        LocalTime id = LocalTime.now();//时 分 秒 纳秒
        System.out.println(id);

        //1、获取时间的信息
        int hour = id.getHour();//时
        int minute = id.getMinute();//分
        int second = id.getSecond();//秒
        int nano = id.getNano();//纳秒

        //2、直接修改时间:withHour、withMinute、withSecond、withNano
        LocalTime id1 = id.withHour(10);
        LocalTime id2 = id.withMinute(10);
        LocalTime id3 = id.withSecond(10);
        LocalTime id4 = id.withNano(10);

        //3、加多少:plusHours、plusMinutes、plusSeconds、plusNanos
        LocalTime id5 = id.plusHours(2);
        LocalTime id6 = id.plusMinutes(2);
        LocalTime id7 = id.plusSeconds(2);
        LocalTime id8 = id.plusNanos(2);

        //4、减多少:minusHours、minusMinutes、minusSeconds、minusNanos
        LocalTime id9 = id.minusHours(2);
        LocalTime id10 = id.minusMinutes(2);
        LocalTime id11 = id.minusSeconds(2);
        LocalTime id12 = id.minusNanos(2);

        //5、获取指定时间的LocalTime对象:
        // public static LocalTime of(int hour int minute int second)
        LocalTime id13=LocalTime.of(12,12,12);
        LocalTime id14=LocalTime.of(12,12,12);

        //6、判断2个时间，是否相等，在前还是在后:equals isBefore isAfter
        System.out.println(id13.equals(id14));//true
        System.out.println(id13.isAfter(id));//true
        System.out.println(id13.isBefore(id)); //false
    }
}
